package subumbo.demo.view.selector {
	import flash.events.MouseEvent;
	
	import mx.controls.Alert;
	
	import org.robotlegs.mvcs.Mediator;
	
	import subumbo.demo.controller.signal.LanguageChange;
	import subumbo.demo.model.CopyModel;

	public class SelectorMediator extends Mediator {
		
		[Inject] public var _view:Selector;
		[Inject] public var laguageChange:LanguageChange;
		[Inject] public var copyModel:CopyModel;
		
		public override function onRegister():void {
			_view.en.addEventListener(MouseEvent.MOUSE_DOWN, englishHandler);
			_view.de.addEventListener(MouseEvent.MOUSE_DOWN, germanHandler);
		}
		
		private function englishHandler(e:MouseEvent):void {
			copyModel.language = "en";
			laguageChange.dispatch();
		}
		
		private function germanHandler(e:MouseEvent):void {
			copyModel.language = "de";
			laguageChange.dispatch();
		}
	}
}